<?php
class Log
{
	public $handle = null;
	public function __construct()
	{

		$file = LOGDIR.date('Y-m-d').'.log';
			if (!is_dir(LOGDIR))
			{
				mkdir(LOGDIR, 0777, true);
				chmod($file, 0777);
			}
		$this->handle = fopen($file,'a');
	}
	
	public function write($msg)
	{
		fwrite($this->handle, '['.date('Y-m-d H:i:s').']'.$msg."\r\n", 4096);
	}
	
	public function __destruct()
	{
		fclose($this->handle);
	}
 
}
